#include "startscene.h"


StartScene::StartScene(QWidget *parent) : MyMainWindow(parent)
{
    //开始按钮
    startButton = new MyButton(":/res/MenuSceneStartButton.png",
                               ":/res/MenuSceneStartButton.png", this);
    startButton->resize(114, 114);
    startButton->move(this->width() / 2 - startButton->width() / 2,
                      this->height() * 3 / 4 - startButton->height() / 2);

    //选择关卡页面
    selScene = new SelScene(this);

    //开始按钮的点击效果
    connect(startButton, &MyButton::clicked, [=](){
        //音效
        SoundUtil s;
        s.actSound();
        //设置点击事件不可用
        startButton->setEnabled(false);
        //向下的动画特效
        startButton->buttonDown();
        //计时器，等待执行完毕
        QTimer::singleShot(150,[=](){
            //完毕之后执行向上动画
            startButton->buttonUp();
        });
        //计时器恢复点击事件
        QTimer::singleShot(300,[=](){
            startButton->setEnabled(true);
        });

        //切换场景
        this->hide();
        selScene->move(this->pos());
        selScene->show();
    });

    //返回到开始页面，返回按钮的实现
    connect(selScene, &SelScene::backButtonSig, this, [=](){
        //音效
        SoundUtil s;
        s.backSound();

        selScene->hide();
        this->move(selScene->pos());
        this->show();
    });
}
